// Dom7
var $$ = Dom7;

// Framework7 App main instance
var app = new Framework7({
	root: '#app', // App root element
	id: 'io.yachtar.app', // App bundle ID
  	name: 'Yachtar', // App name
	theme: 'auto', // Automatic theme detection
	dialog: {
		// set default title for all dialog shortcuts
		title: '提示',
		// change default "OK" button text
		buttonOk: '确认',
	  }
});

// Init/Create main view
var mainView = app.views.create('.view', {
	url: '/'
});

$(document).ready(function(){
	var serialno = sessionStorage.getItem("serialno");
	var givetype = sessionStorage.getItem("givetype");
	call_remote(REQUEST_TYPE814,{serialno:serialno,givetype:givetype},function(data){
		$("#xmmc").val(data[0].description);
		$("#applyamount").val(data[0].applyamount);
		$("#area_sum").val(data[0].area_sum);
		$("#housecount").val(data[0].housecount);
		$("#description").val(data[0].description);
		$("#unitname").val(data[0].unitid_chs);
	});
	call_remote(REQUEST_TYPE842,{serialno:serialno,printname:'wxzjsypqtjb',givetype:'0'},function(data){
		var list2 = data.list2;
		if(list2.length > 0) {
			for (var i = 0; i < list2.length; i++) {
				if(list2[i].TICKETFLAG=="同意"){
					$("#yhouse").text(list2[i].ICOUNT);
					$("#yhouserate").text(list2[i].PERSONRATE);
					$("#yarea").text(list2[i].AREA);
					$("#yareatate").text(list2[i].AREARATE);
				}
				if(list2[i].TICKETFLAG=="反对"){
					$("#nhouse").text(list2[i].ICOUNT);
					$("#nhouserate").text(list2[i].PERSONRATE);
					$("#narea").text(list2[i].AREA);
					$("#nareatate").text(list2[i].AREARATE);
				}
				if(list2[i].TICKETFLAG=="弃权"){
					$("#ihouse").text(list2[i].ICOUNT);
					$("#ihouserate").text(list2[i].PERSONRATE);
					$("#iarea").text(list2[i].AREA);
					$("#iareatate").text(list2[i].AREARATE);
				}
				if(list2[i].TICKETFLAG=="未征询"){
					$("#ohouse").text(list2[i].ICOUNT);
					$("#ohouserate").text(list2[i].PERSONRATE);
					$("#oarea").text(list2[i].AREA);
					$("#oareatate").text(list2[i].AREARATE);
				}
			}
		}
	});
});


//返回
$$('#backimg').on('click', function () {
	window.location.href = "../../plugin/vote/votechoose.html";
});
$$('#housedetail').on('click', function () {
	window.location.href = "../../plugin/vote/housedetail.html";
});
$$('#btnimg').on('click', function () {
	var ischeck = document.getElementById("isread").checked;
	if(ischeck){
		//window.location.href = "../../plugin/vote/waitcard.html";
		cordova.exec(success, fail, "MyFunction", "calljava", ["haha"]);
	}else{
		app.dialog.alert("请先确认已阅读！");
	}
});

var success = function(message){
};
var fail = function(message){
   alert("fail = "+message);
};

 function showAlert(content){
 	var obj = JSON.parse(content);
	/*alert(obj.name);
	alert(obj.id);
	alert(obj.head);*/
	sessionStorage.setItem("cardname",obj.name);
	sessionStorage.setItem("cardid",obj.id);
	sessionStorage.setItem("cardimg",obj.head);
	window.location.href = "../../plugin/vote/carddetail.html";
}
